Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If absent, do not try to close fp when closing image #7557

Merged

Conversation

RaphaelVRossi
Copy link
Contributor

Changes proposed in this pull request:

  • Closes image when they are copied
  • Since image copied doesn't have 'fp' attribute, a message was logged as "error"

def test_close_graceful(self):
with Image.open("Tests/images/hopper.jpg") as im:
copy = im.copy()
im.close()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line isn't strictly necessary to test the change. Are you closing im here just to be thorough and ensure that it also doesn't log any errors?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah! 👍

Tests/test_image.py Outdated Show resolved Hide resolved
Do not assign new fp attribute to image when closing
@radarhere radarhere changed the title fix: check object Image has attribute 'fp' when closes If absent, do not try to close fp when closing image Nov 17, 2023
@radarhere radarhere merged commit f8d061c into python-pillow:main Nov 24, 2023
56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants